<script setup lang="ts">
import { PostModel } from '@/api/post/response';
import { defineProps } from 'vue';

const { post } = defineProps<{
  post: PostModel
}>();

function gotoPost() {
  if (post.isOutlink) {
    window.open(post.linkUrl, "_blank");
  }
}

</script>

<template>
  <div class="postmain" @click="gotoPost">
    <div class="category">
      <span class="icon">
        <svg t="1741076305875" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
          p-id="4339" width="200" height="200">
          <path
            d="M810.666667 0H213.333333C142.613333 0 85.333333 57.28 85.333333 128v768c0 70.72 57.28 128 128 128h597.333334c70.72 0 128-57.28 128-128V128c0-70.72-57.28-128-128-128z m42.666666 896c0 23.573333-19.093333 42.666667-42.666666 42.666667H213.333333c-23.573333 0-42.666667-19.093333-42.666666-42.666667V128c0-23.573333 19.093333-42.666667 42.666666-42.666667h597.333334c23.573333 0 42.666667 19.093333 42.666666 42.666667v768zM682.666667 725.333333H341.333333a42.666667 42.666667 0 0 0 0 85.333334h341.333334a42.666667 42.666667 0 0 0 0-85.333334z m0-170.666666H341.333333a42.666667 42.666667 0 0 0 0 85.333333h341.333334a42.666667 42.666667 0 0 0 0-85.333333z m0-170.666667H341.333333a42.666667 42.666667 0 0 0 0 85.333333h341.333334a42.666667 42.666667 0 0 0 0-85.333333z m-341.333334-85.333333h170.666667a42.666667 42.666667 0 0 0 0-85.333334H341.333333a42.666667 42.666667 0 0 0 0 85.333334z"
            p-id="4340" fill="#ffffff"></path>
        </svg>
      </span>
      <span>
        {{ post.category }}
      </span>
    </div>
    <div class="title">
      <h2>{{ post.title }}</h2>
    </div>
    <div class="desc">
      <p>
        {{ post.desc }}
      </p>
    </div>
    <div class="footer">
      <div class="tag">
        <span v-for="item in post.tags" :key="item">#{{ item }}</span>
      </div>
      <div class="time">
        <span>{{ post.time }}</span>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.postmain {
  cursor: pointer;
  width: 80%;
  height: auto;
  padding: 25px 30px;
  margin: 20px auto;
  position: relative;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  cursor: pointer;

  &::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    padding: 3px;
    background: linear-gradient(45deg, #00ffcc, #ff33cc);
    -webkit-mask:
      linear-gradient(#fff 0 0) content-box,
      linear-gradient(#fff 0 0);
    mask:
      linear-gradient(#fff 0 0) content-box,
      linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    box-shadow: 0 0 20px rgba(0, 255, 204, 0.7), 0 0 40px rgba(255, 51, 204, 0.7);
  }

  &:hover::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg,
        transparent 25%,
        rgba(255, 255, 255, 0.5) 50%,
        transparent 75%);
    animation: shine 1s infinite linear;
    z-index: 0;
  }

  .category {
    font-size: 14px;
    color: #a0a0a0;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 1;

    .icon {
      width: 35px;
      height: 25px;

      svg path {
        fill: #d0d0d0;
      }
    }
  }

  .title {
    margin-top: 20px;
    position: relative;
    z-index: 1;

    h2 {
      line-height: 1.2;
      font-size: 32px;
      font-weight: bold;
      letter-spacing: 2px;
      color: #ffffff;
      text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }
  }

  .desc {
    margin-top: 15px;
    color: #c0c0c0;
    position: relative;
    z-index: 1;
    font-size: 16px;
    line-height: 1.6;

    p {
      width: 1000px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }

  .footer {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    position: relative;
    z-index: 1;

    .tag {
      display: flex;
      gap: 15px;

      span {
        padding: 6px 15px;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 25px;
        color: #909090;
        font-size: 14px;
        transition: all 0.2s ease;

        &:hover {
          background: rgba(255, 255, 255, 0.2);
          color: #fff;
        }
      }
    }

    .time {
      color: #808080;
      font-size: 14px;
      display: flex;
      align-items: center;
    }
  }
}

@keyframes shine {
  0% {
    transform: rotate(45deg) translateX(-50%);
  }

  100% {
    transform: rotate(45deg) translateX(50%);
  }
}
</style>
